<?php
		session_start();
		require("inc/functions.php");
	 	require_once('inc/facebook.php');
	 	$facebook = new Facebook(array(
	 	'appId' => '266106703516634',
	 	'secret' => '57f64882d938b38d36f88185fc2fd78d'
		));
		
		$fbUser = $facebook->getUser();
		
		if(isset($_POST['login']))
			LoginUser($_POST);
	require_once("inc/models/products_model.php");
	if(isset($_GET['catID']))
		$results = GetProductByCat($_GET['catID']);
	else
		$results = GetProducts();
	require_once("inc/models/product_category_model.php");
	$categories = GetProductCategories();
	include("inc/views/header_view.php");
	include("inc/views/navbar_view.php");
?>
<div class="container-fluid">
      <div class="row-fluid">
        <div class="span3">
          <div class="well sidebar-nav">
            <ul class="nav nav-list">
              <li class="nav-header">Categories</li>
              <? while($cat = $categories->fetch_assoc()) : ?>
              <li><a href="products.php?catID=<?=$cat['id']?>"><?=$cat['name']?></a></li>
              <?php endwhile; ?>
            </ul>
          </div><!--/.well -->
        </div><!--/span-->
        <div class="span9">
        	<? if($fbUser): ?>
		<img src="http://graph.facebook.com/<?=$fbUser?>/picture" />
	 	<a href="<?=$facebook->getLogoutUrl()?>">Log Out</a>
	 	<? else: ?>
	 	<a href="<?=$facebook->getLoginUrl(array('scope' => 'read_stream, friends_likes'))?>">
	 	Log in with Facebook
		</a>
	<? endif; ?>
          <div class="row-fluid">
			<? while($rs = $results->fetch_assoc()): ?>
            	<div style="width: 150px; float: left; margin: 5px;">
                	<div style="height: 150px;">
                    	<img src="inc/images/thumbnails/<?=$rs['thumbnail']?>" />
                    </div>
                    <h6><?=$rs['name']?> </h6>
                    <h5>Price: <?=$rs['price']?></h5>
                    <a class="add-to-cart-link" href="cart.php?id=<?=$rs['id']?>"><img src="inc/images/btn_add_to_cart.png"</a>
                </div>
            <? endwhile; ?>
	      </div><!--/row-->
      
      <?php
	include("inc/views/footer_view.php");
?>